package com.example.demo.convert;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.domain.app.vo.CategoryInfoVO;
import com.example.demo.domain.app.vo.ProductVO;
import com.example.demo.domain.entity.ProductCategoryDO;
import com.example.demo.domain.entity.ProductDO;
import com.example.demo.domain.entity.ProductManagementDO;
import com.example.demo.domain.param.ProductCategoryCreateParam;
import com.example.demo.domain.param.ProductCategoryUpdateParam;
import com.example.demo.domain.param.ProductManagementParam;
import com.example.demo.domain.param.ProductManagementUpdateParam;
import com.example.demo.domain.vo.CategorySelectVO;
import com.example.demo.domain.vo.CategoryVO;
import com.example.demo.domain.vo.ProductManagementDetailVO;
import com.example.demo.domain.vo.ProductManagementVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * ProductConvert
 *
 * @author haochen78
 * @date 2025/10/7 21:17
 **/
@Mapper
public interface ProductConvert {

    ProductConvert INSTANCE = Mappers.getMapper(ProductConvert.class);

    List<CategoryVO> categoryDoToVoList(List<ProductCategoryDO> productCategoryDOS);

    ProductManagementDetailVO doToVo(ProductManagementDO productManagementDO);

    ProductCategoryDO categoryCreateParToDo(ProductCategoryCreateParam param);

    ProductCategoryDO categoryUpdateParToDo(ProductCategoryUpdateParam param);

    Page<ProductManagementVO> doToVoPage(Page<ProductManagementDO> page);

    ProductManagementDO managementParToDo(ProductManagementParam param);

    ProductManagementDO managementUpdateSelectiveParToDo(ProductManagementUpdateParam param);

    @Mapping(target = "title", source = "name")
    @Mapping(target = "value", source = "id")
    CategorySelectVO categoryDoToSelectVoList(ProductCategoryDO category);

    List<CategorySelectVO> categoryDoToSelectVoList(List<ProductCategoryDO> categoryList);

    Page<ProductVO> do2VoPage(Page<ProductDO> pageResult);

    @Mapping(target = "pid", source = "parentId")
    CategoryInfoVO categoryDo2Vo(ProductCategoryDO productCategory);

    List<CategoryInfoVO> categoryDo2VoList(List<ProductCategoryDO> productCategoryList);
}
